<%
    String manager = (String) session.getAttribute("loggedUser");
    if( manager != null ) {
%>
<%@page import="java.util.List"%>
<%@page import="DAO.DAO_Category"%>
<%@page import="Entity.Category"%>
<%@page import="Tools.AccentRemover"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Dashboard</title>
        <link rel="stylesheet" href="Assets/css/bootstrap.min.css" />
        <link rel="stylesheet" href="Assets/css/font-awesome.min.css" />
        <link rel="stylesheet" href="Assets/css/jquery.contextMenu.css" />
        <link rel="stylesheet" href="Assets/css/dashboard.css" />
        <link rel="stylesheet" href="Assets/css/jquery.tagsinput.css" />
        <link rel="stylesheet" href="Assets/css/style.css" />
        <script src="Assets/js/jquery-2.1.1.min.js"></script>        
        <script src="Assets/js/bootstrap.min.js"></script>
        <script src="Assets/js/jquery.contextMenu.js"></script>
        <script src="Assets/js/myscript.js"></script>
    </head>
    <body>
        <div class="container-fluid">
            <div class="row">
                <%@ include file="includes/adminSidebar.jsp" %>
                <div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main">
                    <%
                        String view = request.getParameter("view");
                        if(view == null) {
                            %>
                            <%@ include file="includes/adminListContent.jsp" %>
                            <%
                        }else if(view.equalsIgnoreCase("add-content")) {
                            %>
                            <%@ include file="includes/adminAddContent.jsp" %>
                            <%                            
                        }else if(view.equalsIgnoreCase("delete-content")) {
                            %>
                            <%@ include file="includes/adminDeleteContent.jsp" %>
                            <%                            
                        }else if(view.equalsIgnoreCase("edit-content")) {
                            %>
                            <%@ include file="includes/adminUpdateContent.jsp" %>
                            <%                            
                        }else if(view.equalsIgnoreCase("category")) {
                            %>
                            <%@ include file="includes/adminViewCategory.jsp" %>
                            <%                            
                        }else if(view.equalsIgnoreCase("delete-category")) {
                            String cid = request.getParameter("cid");
                            if(cid!=null) {
                                int did = 0;
                                did = Integer.parseInt(cid);
                                DAO_Category daocatdel = new DAO_Category();
                                int n = daocatdel.deleteCategory(did);
                                if(n > 0 ) response.sendRedirect("Dashboard.jsp");
                                daocatdel.closeConnection();
                            }
                        }else if(view.equalsIgnoreCase("logout")) {
                            session.invalidate();
                            response.sendRedirect("Login.jsp");
                        }
                    %>
                </div>
            </div>
        </div>
            <div class="footercp">
                <a href="Index.jsp">Homepage</a> |
                <a href="Dashboard.jsp">CMS Dashboard</a> | 
                <a href="Student.jsp">Students Management</a> | 
                <a href="Dashboard.jsp?view=logout">Logout</a>
                
            </div>                
    </body>
</html>
<% } else {
        response.sendRedirect("Login.jsp");
    }
%>